#include "Network.h"

Network::Network(std::string name, float quality, EncryptionType enc, std::string psk):
my_name(name),
my_quality(quality),
my_enc(enc),
my_psk(psk)
{};

Network::Network(std::string desc):
my_psk()
{
	size_t start = desc.find("\"", desc.find("ESSID")) + 1;
	size_t size = desc.find("\"", start) - start;
	my_name = desc.substr(start, size);
	
	my_enc = WPA_ENCRYPTION;
	size = desc.find("/", start) - start;
		
	float top = atof(desc.substr(start, size).c_str());
	start = start+size+1;
	float bottom = atof(desc.substr(start, 3).c_str());
	
	my_quality = top / bottom;
}
